#ifndef _CSETYPES_H_CSEAPI_
#define _CSETYPES_H_CSEAPI_

#ifdef _WIN32
  #undef __BIT64SYS__

  #ifndef __WINDOWS__
    #define __WINDOWS__
  #endif
#endif

#ifdef _WIN64
  #ifndef _WIN32
    #define _WIN32   // define it for compatibility reasons
  #endif

  #ifndef __BIT64SYS__
    #define __BIT64SYS__
  #endif

  #ifndef __WINDOWS__
    #define __WINDOWS__
  #endif
#endif

#if defined(_UNICODE)
  #undef CSE_USE_UNICODE
  #define CSE_USE_UNICODE          1
#else
  #ifndef CSE_USE_UNICODE
    #define CSE_USE_UNICODE        0
  #endif
#endif

#if CSE_USE_UNICODE
  #ifndef _UNICODE
    #define _UNICODE
  #endif
#endif

// CSE API version and feature: V2.1.0.0
#define CSE_API_VERSION            0x02010000
#if !defined(_UNICODE)
  #define CSE_FEATURE_FLAG         0x00000000     // SBCS
#else
  #define CSE_FEATURE_FLAG         0x00000001     // unicode
#endif

#ifndef NULL
  #ifdef  __cplusplus
    #define NULL                   0
  #else
    #define NULL                   ((void *)0)
  #endif
#endif

#if defined(_MSC_VER) && !defined(__cplusplus)
  #ifndef true
    #define true                   1
  #endif
  
  #ifndef false
    #define false                  0
  #endif
#endif

#if defined(__WINDOWS__)
  #if defined(_MSC_VER) && _MSC_VER >= 1200 // support VC6 and later version
    // rename usage of "struct tm" that declared in time.h
    #define struct_tm struct tm
  
    #ifndef _WCHAR_T_DEFINED
      typedef unsigned short wchar_t;
      #define _WCHAR_T_DEFINED
    #endif

    #ifndef _VA_LIST_DEFINED
      typedef char* va_list;
      #define _VA_LIST_DEFINED
    #endif

    typedef char                   TChar;
    typedef wchar_t                TWchar;

    typedef char                   TInt8;
    typedef unsigned char          TUint8;
    typedef short                  TInt16;
    typedef unsigned short         TUint16;
    typedef __int32                TInt32;
    typedef unsigned __int32       TUint32;
    typedef __int64                TInt64;
    typedef unsigned __int64       TUint64;
    typedef float                  TFloat;
    typedef double                 TDouble;

    typedef long                   TLong;
    typedef unsigned long          TUlong;
    
    #ifdef __cplusplus
      typedef bool                 TBool;
    #else
      typedef TInt8                TBool;
    #endif

    typedef size_t                 TSize_t;  // size_t is standard type in CSE
    typedef void                   TVoid;    // void is standard type in CSE

    #ifdef _UNICODE
      typedef wchar_t              TXchar;
    #else
      typedef char                 TXchar;
    #endif

    // sizeof(TInt) in 32-bits system is 4 bytes, and in 64-bits is 8
    typedef int                    TInt;
    typedef unsigned int           TUint;

    // sizeof(TWint) is 8 bytes both in 32-bits and 64-bits system
    typedef __int64                TWint;
    typedef unsigned __int64       TUwint;
  #endif
#endif

#endif
